package code;

import java.util.Arrays;

/**
 * <p>
 * 冒泡排序
 * </p>
 *
 * @author xiaovcloud
 * @since 2021/8/15 下午10:49
 */
public class BubbleSortTest {
    public static void main(String[] args) {
        Integer[] arr = {10, 4, 2, 7, 5, 19, 11, 33, 28};
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void sort(Integer[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j + 1] < arr[j]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
}
